package com.orange.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.orange.domain.StatBean;
import com.orange.domain.User;
import com.orange.domain.VisitLog;
import com.orange.dto.StatDto;
import com.orange.dto.VisitLogDto;
import com.orange.mapper.VisitLogMapper;
import com.orange.service.VisitLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VisitLogServiceImpl implements VisitLogService {

    @Resource
    private VisitLogMapper visitLogMapper;

    @Override
    public int insert(VisitLog record) {
        return visitLogMapper.insert(record);
    }

    @Override
    public int insertSelective(VisitLog record) {
        return visitLogMapper.insertSelective(record);
    }

    @Override
    public PageInfo<VisitLog> queryByPage(VisitLogDto visitLogDto) {
        Page<VisitLog> page = PageHelper.startPage(visitLogDto.getPage(), visitLogDto.getLimit());
        List<VisitLog> visitLogList = visitLogMapper.queryAll(visitLogDto);
        return page.toPageInfo();
    }

    @Override
    public List<StatBean> statVisitCount(StatDto statDto) {
        return visitLogMapper.statVisitCount(statDto);
    }

    @Override
    public void updateRealname(User user) {
        visitLogMapper.updateRealname(user);
    }

}
